package com.smart.five.ioc.factorybean;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 测试类
 *
 * @author junrui.wang
 * @create 2018/6/14
 */
public class Test {
    public static void main(String[] args) {
        ApplicationContext ac = new ClassPathXmlApplicationContext("classpath*:com/smart/five/ioc/factorybean/beans.xml");
        Car car1 = (Car) ac.getBean("car");
        System.out.println(car1);
        Car car2 = (Car) ac.getBean("car");
        System.out.println(car2);

        //如果用户希望获取CarFactoryBean实例，需要在getBean()方法的beanName前面显式的加上&，getBean(&beanName)
        CarFactoryBean carFactoryBean = (CarFactoryBean) ac.getBean("&car");
        System.out.println(carFactoryBean);
    }
}
